#include "define.h"
#include <stdio.h>
#include <stdbool.h>
#include <allegro5/allegro5.h>
#include <allegro5/allegro_image.h>

typedef struct
{
    ALLEGRO_BITMAP* _sheet;
    ALLEGRO_BITMAP* pieces[14];
    ALLEGRO_BITMAP* pieces_crack[CRACK_FRAME];
} PIECES;

typedef struct {
    ALLEGRO_BITMAP* _sheet;
    ALLEGRO_BITMAP* piece_select[2];
    int x;
    int y;
    bool selected;
    int select_x;
    int select_y;
} PSELECT;

typedef struct {
    ALLEGRO_BITMAP* _sheet;
    bool board[BOARD_ROW][BOARD_COL];
} SHADOW;

ALLEGRO_BITMAP* pieces_grab(int x, int y, int w, int h);
void pieces_init();
void pieces_clean();
int get_pieces(int board);
void pieces_draw();

ALLEGRO_BITMAP* pselect_grab(int x, int y, int w, int h);
void pselect_init();
void pselect_clean();
void pselect_update(ALLEGRO_EVENT *event);
void pselect_draw();


bool is_ally(int self, int piece);
bool is_enemy(int self, int piece);
bool movable(int self, int piece);
bool is_checkmate();
void shadow_init();
void shadow_clean();
void shadow_update();
void shadow_mark(int x, int y);
void shadow_draw();
void move_piece(int x, int y, int x1, int y1);


void eat_piece(int x1, int y1);